package workflow

import (
	"fmt"
)

type WorkFlowStatistic struct {
	totalTime   int64
	count       int64
	averageTime int64
	name        string
}

func NewWorkFlowStatistic() *WorkFlowStatistic {
	return &WorkFlowStatistic{}
}

func (s *WorkFlowStatistic) GetName() string {
	return s.name
}

func (s *WorkFlowStatistic) SetName(name string) {
	s.name = name
}

func (s *WorkFlowStatistic) GetTotalTime() int64 {
	return s.totalTime
}

func (s *WorkFlowStatistic) SetTotalTime(totalTime int64) {
	s.totalTime = totalTime
}

func (s *WorkFlowStatistic) GetCount() int64 {
	return s.count
}

func (s *WorkFlowStatistic) SetCount(count int64) {
	s.count = count
}

func (s *WorkFlowStatistic) GetAverageTime() int64 {
	return s.averageTime
}

func (s *WorkFlowStatistic) SetAverageTime(averageTime int64) {
	s.averageTime = averageTime
}

func (s *WorkFlowStatistic) AddStatistic(t int64) {
	s.totalTime += t
	s.count++
	s.averageTime = s.totalTime / s.count
}

func (s *WorkFlowStatistic) String() string {
	return fmt.Sprintf("Flow[%s]: total time: %d secs, total count: %d, average time: %d secs",
		s.name, s.totalTime, s.count, s.averageTime)
}
